﻿
/// <reference path="jquery-1.5.1-vsdoc.js" />

/**
* Interface Elements for jQuery
* utility function
*
* http://interface.eyecon.ro
*
* Copyright (c) 2006 Stefan Petre
* Dual licensed under the MIT (MIT-LICENSE.txt)
* and GPL (GPL-LICENSE.txt) licenses.
*
*
*/

jQuery.iUtil={getPosition:function(c){var f=0;var g=0;var a=false;var b=c.style;if(jQuery(c).css("display")=="none"){oldVisibility=b.visibility;oldPosition=b.position;b.visibility="hidden";b.display="block";b.position="absolute";a=true}var d=c;while(d){f+=d.offsetLeft+(d.currentStyle&&!jQuery.browser.opera?parseInt(d.currentStyle.borderLeftWidth)||0:0);g+=d.offsetTop+(d.currentStyle&&!jQuery.browser.opera?parseInt(d.currentStyle.borderTopWidth)||0:0);d=d.offsetParent}d=c;while(d&&d.tagName&&d.tagName.toLowerCase()!="body"){f-=d.scrollLeft||0;g-=d.scrollTop||0;d=d.parentNode}if(a){b.display="none";b.position=oldPosition;b.visibility=oldVisibility}return{x:f,y:g}},getPositionLite:function(a){var b=0,c=0;while(a){b+=a.offsetLeft||0;c+=a.offsetTop||0;a=a.offsetParent}return{x:b,y:c}},getSize:function(c){var f=jQuery.css(c,"width");var a=jQuery.css(c,"height");var g=0;var d=0;var b=c.style;if(jQuery(c).css("display")!="none"){g=c.offsetWidth;d=c.offsetHeight}else{oldVisibility=b.visibility;oldPosition=b.position;b.visibility="hidden";b.display="block";b.position="absolute";g=c.offsetWidth;d=c.offsetHeight;b.display="none";b.position=oldPosition;b.visibility=oldVisibility}return{w:f,h:a,wb:g,hb:d}},getSizeLite:function(a){return{wb:a.offsetWidth||0,hb:a.offsetHeight||0}},getClient:function(c){var a,d,b;if(c){d=c.clientWidth;a=c.clientHeight}else{b=document.documentElement;d=window.innerWidth||self.innerWidth||(b&&b.clientWidth)||document.body.clientWidth;a=window.innerHeight||self.innerHeight||(b&&b.clientHeight)||document.body.clientHeight}return{w:d,h:a}},getScroll:function(b){var f,c,d,a,i,g;if(b&&b.nodeName.toLowerCase()!="body"){f=b.scrollTop;c=b.scrollLeft;d=b.scrollWidth;a=b.scrollHeight;i=0;g=0}else{if(document.documentElement&&document.documentElement.scrollTop){f=document.documentElement.scrollTop;c=document.documentElement.scrollLeft;d=document.documentElement.scrollWidth;a=document.documentElement.scrollHeight}else{if(document.body){f=document.body.scrollTop;c=document.body.scrollLeft;d=document.body.scrollWidth;a=document.body.scrollHeight}}i=self.innerWidth||document.documentElement.clientWidth||document.body.clientWidth||0;g=self.innerHeight||document.documentElement.clientHeight||document.body.clientHeight||0}return{t:f,l:c,w:d,h:a,iw:i,ih:g}},getMargins:function(d,i){var a=jQuery(d);var h=a.css("marginTop")||"";var c=a.css("marginRight")||"";var g=a.css("marginBottom")||"";var f=a.css("marginLeft")||"";if(i){return{t:parseInt(h)||0,r:parseInt(c)||0,b:parseInt(g)||0,l:parseInt(f)}}else{return{t:h,r:c,b:g,l:f}}},getPadding:function(d,i){var a=jQuery(d);var h=a.css("paddingTop")||"";var c=a.css("paddingRight")||"";var g=a.css("paddingBottom")||"";var f=a.css("paddingLeft")||"";if(i){return{t:parseInt(h)||0,r:parseInt(c)||0,b:parseInt(g)||0,l:parseInt(f)}}else{return{t:h,r:c,b:g,l:f}}},getBorder:function(d,i){var a=jQuery(d);var h=a.css("borderTopWidth")||"";var c=a.css("borderRightWidth")||"";var g=a.css("borderBottomWidth")||"";var f=a.css("borderLeftWidth")||"";if(i){return{t:parseInt(h)||0,r:parseInt(c)||0,b:parseInt(g)||0,l:parseInt(f)||0}}else{return{t:h,r:c,b:g,l:f}}},getPointer:function(a){var b=a.pageX||(a.clientX+(document.documentElement.scrollLeft||document.body.scrollLeft))||0;var c=a.pageY||(a.clientY+(document.documentElement.scrollTop||document.body.scrollTop))||0;return{x:b,y:c}},traverseDOM:function(b,a){a(b);b=b.firstChild;while(b){jQuery.iUtil.traverseDOM(b,a);b=b.nextSibling}},purgeEvents:function(a){jQuery.iUtil.traverseDOM(a,function(b){for(var c in b){if(typeof b[c]==="function"){b[c]=null}}})},centerEl:function(a,d){var b=$.iUtil.getScroll();var c=$.iUtil.getSize(a);if(!d||d=="vertically"){$(a).css({top:b.t+((Math.max(b.h,b.ih)-b.t-c.hb)/2)+"px"})}if(!d||d=="horizontally"){$(a).css({left:b.l+((Math.max(b.w,b.iw)-b.l-c.wb)/2)+"px"})}},fixPNG:function(a,c){var d=$('img[@src*="png"]',a||document),b;d.each(function(){b=this.src;this.src=c;this.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+b+"')"})}};[].indexOf||(Array.prototype.indexOf=function(c,b){b=(b==null)?0:b;var d=this.length;for(var a=b;a<d;a++){if(this[a]==c){return a}}return -1});

/**
* Interface Elements for jQuery
* Draggable
*
* http://interface.eyecon.ro
*
* Copyright (c) 2006 Stefan Petre
* Dual licensed under the MIT (MIT-LICENSE.txt)
* and GPL (GPL-LICENSE.txt) licenses.
*/

/**
* Create a draggable element with a number of advanced options including callback, Google Maps type draggables,
* reversion, ghosting, and grid dragging.
* 
* @name Draggable
* @descr Creates draggable elements that can be moved across the page.
* @param Hash hash A hash of parameters. All parameters are optional.
* @option String handle (optional) The jQuery selector matching the handle that starts the draggable
* @option DOMElement handle (optional) The DOM Element of the handle that starts the draggable
* @option Boolean revert (optional) When true, on stop-drag the element returns to initial position
* @option Boolean ghosting (optional) When true, a copy of the element is moved
* @option Integer zIndex (optional) zIndex depth for the element while it is being dragged
* @option Float opacity (optional) A number between 0 and 1 that indicates the opacity of the element while being dragged
* @option Integer grid (optional) (optional) A number of pixels indicating the grid that the element should snap to
* @option Array grid (optional) A number of x-pixels and y-pixels indicating the grid that the element should snap to
* @option Integer fx (optional) Duration for the effect (like ghosting or revert) applied to the draggable
* @option String containment (optional) Define the zone where the draggable can be moved. 'parent' moves it inside parent
*                           element, while 'document' prevents it from leaving the document and forcing additional
*                           scrolling
* @option Array containment An 4-element array (left, top, width, height) indicating the containment of the element
* @option String axis (optional) Set an axis: vertical (with 'vertically') or horizontal (with 'horizontally')
* @option Function onStart (optional) Callback function triggered when the dragging starts
* @option Function onStop (optional) Callback function triggered when the dragging stops
* @option Function onChange (optional) Callback function triggered when the dragging stop *and* the element was moved at least
*                          one pixel
* @option Function onDrag (optional) Callback function triggered while the element is dragged. Receives two parameters: x and y
*                        coordinates. You can return an object with new coordinates {x: x, y: y} so this way you can
*                        interact with the dragging process (for instance, build your containment)
* @option Boolean insideParent Forces the element to remain inside its parent when being dragged (like Google Maps)
* @option Integer snapDistance (optional) The element is not moved unless it is dragged more than snapDistance. You can prevent
*                             accidental dragging and keep regular clicking enabled (for links or form elements, 
*                             for instance)
* @option Object cursorAt (optional) The dragged element is moved to the cursor position with the offset specified. Accepts value
*                        for top, left, right and bottom offset. Basically, this forces the cursor to a particular
*                        position during the entire drag operation.
* @option Boolean autoSize (optional) When true, the drag helper is resized to its content, instead of the dragged element's sizes
* @option String frameClass (optional) When is set the cloned element is hidden so only a frame is dragged
* @type jQuery
* @cat Plugins/Interface
* @author Stefan Petre
*/

jQuery.iDrag={helper:null,dragged:null,destroy:function(){return this.each(function(){if(this.isDraggable){this.dragCfg.dhe.unbind("mousedown",jQuery.iDrag.draginit);this.dragCfg=null;this.isDraggable=false;if(jQuery.browser.msie){this.unselectable="off"}else{this.style.MozUserSelect="";this.style.KhtmlUserSelect="";this.style.userSelect=""}}})},draginit:function(a){if(jQuery.iDrag.dragged!=null){jQuery.iDrag.dragstop(a);return false}var b=this.dragElem;jQuery(document).bind("mousemove",jQuery.iDrag.dragmove).bind("mouseup",jQuery.iDrag.dragstop);b.dragCfg.pointer=jQuery.iUtil.getPointer(a);b.dragCfg.currentPointer=b.dragCfg.pointer;b.dragCfg.init=false;b.dragCfg.fromHandler=this!=this.dragElem;jQuery.iDrag.dragged=b;if(b.dragCfg.si&&this!=this.dragElem){parentPos=jQuery.iUtil.getPosition(b.parentNode);sliderSize=jQuery.iUtil.getSize(b);sliderPos={x:parseInt(jQuery.css(b,"left"))||0,y:parseInt(jQuery.css(b,"top"))||0};dx=b.dragCfg.currentPointer.x-parentPos.x-sliderSize.wb/2-sliderPos.x;dy=b.dragCfg.currentPointer.y-parentPos.y-sliderSize.hb/2-sliderPos.y;jQuery.iSlider.dragmoveBy(b,[dx,dy])}return jQuery.selectKeyHelper||false},dragstart:function(b){var f=jQuery.iDrag.dragged;f.dragCfg.init=true;var c=f.style;f.dragCfg.oD=jQuery.css(f,"display");f.dragCfg.oP=jQuery.css(f,"position");if(!f.dragCfg.initialPosition){f.dragCfg.initialPosition=f.dragCfg.oP}f.dragCfg.oR={x:parseInt(jQuery.css(f,"left"))||0,y:parseInt(jQuery.css(f,"top"))||0};f.dragCfg.diffX=0;f.dragCfg.diffY=0;if(jQuery.browser.msie){var a=jQuery.iUtil.getBorder(f,true);f.dragCfg.diffX=a.l||0;f.dragCfg.diffY=a.t||0}f.dragCfg.oC=jQuery.extend(jQuery.iUtil.getPosition(f),jQuery.iUtil.getSize(f));if(f.dragCfg.oP!="relative"&&f.dragCfg.oP!="absolute"){c.position="relative"}jQuery.iDrag.helper.empty();var g=f.cloneNode(true);jQuery(g).css({display:"block",left:"0px",top:"0px"});g.style.marginTop="0";g.style.marginRight="0";g.style.marginBottom="0";g.style.marginLeft="0";jQuery.iDrag.helper.append(g);var d=jQuery.iDrag.helper.get(0).style;if(f.dragCfg.autoSize){d.width="auto";d.height="auto"}else{d.height=f.dragCfg.oC.hb+"px";d.width=f.dragCfg.oC.wb+"px"}d.display="block";d.marginTop="0px";d.marginRight="0px";d.marginBottom="0px";d.marginLeft="0px";jQuery.extend(f.dragCfg.oC,jQuery.iUtil.getSize(g));if(f.dragCfg.cursorAt){if(f.dragCfg.cursorAt.left){f.dragCfg.oR.x+=f.dragCfg.pointer.x-f.dragCfg.oC.x-f.dragCfg.cursorAt.left;f.dragCfg.oC.x=f.dragCfg.pointer.x-f.dragCfg.cursorAt.left}if(f.dragCfg.cursorAt.top){f.dragCfg.oR.y+=f.dragCfg.pointer.y-f.dragCfg.oC.y-f.dragCfg.cursorAt.top;f.dragCfg.oC.y=f.dragCfg.pointer.y-f.dragCfg.cursorAt.top}if(f.dragCfg.cursorAt.right){f.dragCfg.oR.x+=f.dragCfg.pointer.x-f.dragCfg.oC.x-f.dragCfg.oC.hb+f.dragCfg.cursorAt.right;f.dragCfg.oC.x=f.dragCfg.pointer.x-f.dragCfg.oC.wb+f.dragCfg.cursorAt.right}if(f.dragCfg.cursorAt.bottom){f.dragCfg.oR.y+=f.dragCfg.pointer.y-f.dragCfg.oC.y-f.dragCfg.oC.hb+f.dragCfg.cursorAt.bottom;f.dragCfg.oC.y=f.dragCfg.pointer.y-f.dragCfg.oC.hb+f.dragCfg.cursorAt.bottom}}f.dragCfg.nx=f.dragCfg.oR.x;f.dragCfg.ny=f.dragCfg.oR.y;if(f.dragCfg.insideParent||f.dragCfg.containment=="parent"){parentBorders=jQuery.iUtil.getBorder(f.parentNode,true);f.dragCfg.oC.x=f.offsetLeft+(jQuery.browser.msie?0:jQuery.browser.opera?-parentBorders.l:parentBorders.l);f.dragCfg.oC.y=f.offsetTop+(jQuery.browser.msie?0:jQuery.browser.opera?-parentBorders.t:parentBorders.t);jQuery(f.parentNode).append(jQuery.iDrag.helper.get(0))}if(f.dragCfg.containment){jQuery.iDrag.getContainment(f);f.dragCfg.onDragModifier.containment=jQuery.iDrag.fitToContainer}if(f.dragCfg.si){jQuery.iSlider.modifyContainer(f)}d.left=f.dragCfg.oC.x-f.dragCfg.diffX+"px";d.top=f.dragCfg.oC.y-f.dragCfg.diffY+"px";d.width=f.dragCfg.oC.wb+"px";d.height=f.dragCfg.oC.hb+"px";jQuery.iDrag.dragged.dragCfg.prot=false;if(f.dragCfg.gx){f.dragCfg.onDragModifier.grid=jQuery.iDrag.snapToGrid}if(f.dragCfg.zIndex!=false){jQuery.iDrag.helper.css("zIndex",f.dragCfg.zIndex)}if(f.dragCfg.opacity){jQuery.iDrag.helper.css("opacity",f.dragCfg.opacity);if(window.ActiveXObject){jQuery.iDrag.helper.css("filter","alpha(opacity="+f.dragCfg.opacity*100+")")}}if(f.dragCfg.frameClass){jQuery.iDrag.helper.addClass(f.dragCfg.frameClass);jQuery.iDrag.helper.get(0).firstChild.style.display="none"}if(f.dragCfg.onStart){f.dragCfg.onStart.apply(f,[g,f.dragCfg.oR.x,f.dragCfg.oR.y])}if(jQuery.iDrop&&jQuery.iDrop.count>0){jQuery.iDrop.highlight(f)}if(f.dragCfg.ghosting==false){c.display="none"}return false},getContainment:function(a){if(a.dragCfg.containment.constructor==String){if(a.dragCfg.containment=="parent"){a.dragCfg.cont=jQuery.extend({x:0,y:0},jQuery.iUtil.getSize(a.parentNode));var c=jQuery.iUtil.getBorder(a.parentNode,true);a.dragCfg.cont.w=a.dragCfg.cont.wb-c.l-c.r;a.dragCfg.cont.h=a.dragCfg.cont.hb-c.t-c.b}else{if(a.dragCfg.containment=="document"){var b=jQuery.iUtil.getClient();a.dragCfg.cont={x:0,y:0,w:b.w,h:b.h}}}}else{if(a.dragCfg.containment.constructor==Array){a.dragCfg.cont={x:parseInt(a.dragCfg.containment[0])||0,y:parseInt(a.dragCfg.containment[1])||0,w:parseInt(a.dragCfg.containment[2])||0,h:parseInt(a.dragCfg.containment[3])||0}}}a.dragCfg.cont.dx=a.dragCfg.cont.x-a.dragCfg.oC.x;a.dragCfg.cont.dy=a.dragCfg.cont.y-a.dragCfg.oC.y},hidehelper:function(a){if(a.dragCfg.insideParent||a.dragCfg.containment=="parent"){jQuery("body",document).append(jQuery.iDrag.helper.get(0))}jQuery.iDrag.helper.empty().hide().css("opacity",1);if(window.ActiveXObject){jQuery.iDrag.helper.css("filter","alpha(opacity=100)")}},dragstop:function(b){jQuery(document).unbind("mousemove",jQuery.iDrag.dragmove).unbind("mouseup",jQuery.iDrag.dragstop);if(jQuery.iDrag.dragged==null){return}var d=jQuery.iDrag.dragged;jQuery.iDrag.dragged=null;if(d.dragCfg.init==false){return false}if(d.dragCfg.so==true){jQuery(d).css("position",d.dragCfg.oP)}var c=d.style;if(d.si){jQuery.iDrag.helper.css("cursor","move")}if(d.dragCfg.frameClass){jQuery.iDrag.helper.removeClass(d.dragCfg.frameClass)}if(d.dragCfg.revert==false){if(d.dragCfg.fx>0){if(!d.dragCfg.axis||d.dragCfg.axis=="horizontally"){var f=new jQuery.fx(d,{duration:d.dragCfg.fx},"left");f.custom(d.dragCfg.oR.x,d.dragCfg.nRx)}if(!d.dragCfg.axis||d.dragCfg.axis=="vertically"){var g=new jQuery.fx(d,{duration:d.dragCfg.fx},"top");g.custom(d.dragCfg.oR.y,d.dragCfg.nRy)}}else{if(!d.dragCfg.axis||d.dragCfg.axis=="horizontally"){d.style.left=d.dragCfg.nRx+"px"}if(!d.dragCfg.axis||d.dragCfg.axis=="vertically"){d.style.top=d.dragCfg.nRy+"px"}}jQuery.iDrag.hidehelper(d);if(d.dragCfg.ghosting==false){jQuery(d).css("display",d.dragCfg.oD)}}else{if(d.dragCfg.fx>0){d.dragCfg.prot=true;var a=false;if(jQuery.iDrop&&jQuery.iSort&&d.dragCfg.so){a=jQuery.iUtil.getPosition(jQuery.iSort.helper.get(0))}jQuery.iDrag.helper.animate({left:a?a.x:d.dragCfg.oC.x,top:a?a.y:d.dragCfg.oC.y},d.dragCfg.fx,function(){d.dragCfg.prot=false;if(d.dragCfg.ghosting==false){d.style.display=d.dragCfg.oD}jQuery.iDrag.hidehelper(d)})}else{jQuery.iDrag.hidehelper(d);if(d.dragCfg.ghosting==false){jQuery(d).css("display",d.dragCfg.oD)}}}if(jQuery.iDrop&&jQuery.iDrop.count>0){jQuery.iDrop.checkdrop(d)}if(jQuery.iSort&&d.dragCfg.so){jQuery.iSort.check(d)}if(d.dragCfg.onChange&&(d.dragCfg.nRx!=d.dragCfg.oR.x||d.dragCfg.nRy!=d.dragCfg.oR.y)){d.dragCfg.onChange.apply(d,d.dragCfg.lastSi||[0,0,d.dragCfg.nRx,d.dragCfg.nRy])}if(d.dragCfg.onStop){d.dragCfg.onStop.apply(d)}return false},snapToGrid:function(c,d,b,a){if(b!=0){b=parseInt((b+(this.dragCfg.gx*b/Math.abs(b))/2)/this.dragCfg.gx)*this.dragCfg.gx}if(a!=0){a=parseInt((a+(this.dragCfg.gy*a/Math.abs(a))/2)/this.dragCfg.gy)*this.dragCfg.gy}return{dx:b,dy:a,x:0,y:0}},fitToContainer:function(c,d,b,a){b=Math.min(Math.max(b,this.dragCfg.cont.dx),this.dragCfg.cont.w+this.dragCfg.cont.dx-this.dragCfg.oC.wb);a=Math.min(Math.max(a,this.dragCfg.cont.dy),this.dragCfg.cont.h+this.dragCfg.cont.dy-this.dragCfg.oC.hb);return{dx:b,dy:a,x:0,y:0}},dragmove:function(b){if(jQuery.iDrag.dragged==null||jQuery.iDrag.dragged.dragCfg.prot==true){return}var f=jQuery.iDrag.dragged;f.dragCfg.currentPointer=jQuery.iUtil.getPointer(b);if(f.dragCfg.init==false){distance=Math.sqrt(Math.pow(f.dragCfg.pointer.x-f.dragCfg.currentPointer.x,2)+Math.pow(f.dragCfg.pointer.y-f.dragCfg.currentPointer.y,2));if(distance<f.dragCfg.snapDistance){return}else{jQuery.iDrag.dragstart(b)}}var d=f.dragCfg.currentPointer.x-f.dragCfg.pointer.x;var g=f.dragCfg.currentPointer.y-f.dragCfg.pointer.y;for(var a in f.dragCfg.onDragModifier){var c=f.dragCfg.onDragModifier[a].apply(f,[f.dragCfg.oR.x+d,f.dragCfg.oR.y+g,d,g]);if(c&&c.constructor==Object){d=a!="user"?c.dx:(c.x-f.dragCfg.oR.x);g=a!="user"?c.dy:(c.y-f.dragCfg.oR.y)}}f.dragCfg.nx=f.dragCfg.oC.x+d-f.dragCfg.diffX;f.dragCfg.ny=f.dragCfg.oC.y+g-f.dragCfg.diffY;if(f.dragCfg.si&&(f.dragCfg.onSlide||f.dragCfg.onChange)){jQuery.iSlider.onSlide(f,f.dragCfg.nx,f.dragCfg.ny)}if(f.dragCfg.onDrag){f.dragCfg.onDrag.apply(f,[f.dragCfg.oR.x+d,f.dragCfg.oR.y+g])}if(!f.dragCfg.axis||f.dragCfg.axis=="horizontally"){f.dragCfg.nRx=f.dragCfg.oR.x+d;jQuery.iDrag.helper.get(0).style.left=f.dragCfg.nx+"px"}if(!f.dragCfg.axis||f.dragCfg.axis=="vertically"){f.dragCfg.nRy=f.dragCfg.oR.y+g;jQuery.iDrag.helper.get(0).style.top=f.dragCfg.ny+"px"}if(jQuery.iDrop&&jQuery.iDrop.count>0){jQuery.iDrop.checkhover(f)}return false},build:function(b){if(!jQuery.iDrag.helper){jQuery("body",document).append('<div id="dragHelper"></div>');jQuery.iDrag.helper=jQuery("#dragHelper");var a=jQuery.iDrag.helper.get(0);var c=a.style;c.position="absolute";c.display="none";c.cursor="move";c.listStyle="none";c.overflow="hidden";if(window.ActiveXObject){a.unselectable="on"}else{c.mozUserSelect="none";c.userSelect="none";c.KhtmlUserSelect="none"}}if(!b){b={}}return this.each(function(){if(this.isDraggable||!jQuery.iUtil){return}if(window.ActiveXObject){this.onselectstart=function(){return false};this.ondragstart=function(){return false}}var d=this;var e=b.handle?jQuery(this).find(b.handle):jQuery(this);if(jQuery.browser.msie){e.each(function(){this.unselectable="on"})}else{e.css("-moz-user-select","none");e.css("user-select","none");e.css("-khtml-user-select","none")}this.dragCfg={dhe:e,revert:b.revert?true:false,ghosting:b.ghosting?true:false,so:b.so?b.so:false,si:b.si?b.si:false,insideParent:b.insideParent?b.insideParent:false,zIndex:b.zIndex?parseInt(b.zIndex)||0:false,opacity:b.opacity?parseFloat(b.opacity):false,fx:parseInt(b.fx)||null,hpc:b.hpc?b.hpc:false,onDragModifier:{},pointer:{},onStart:b.onStart&&b.onStart.constructor==Function?b.onStart:false,onStop:b.onStop&&b.onStop.constructor==Function?b.onStop:false,onChange:b.onChange&&b.onChange.constructor==Function?b.onChange:false,axis:/vertically|horizontally/.test(b.axis)?b.axis:false,snapDistance:b.snapDistance?parseInt(b.snapDistance)||0:0,cursorAt:b.cursorAt?b.cursorAt:false,autoSize:b.autoSize?true:false,frameClass:b.frameClass||false};if(b.onDragModifier&&b.onDragModifier.constructor==Function){this.dragCfg.onDragModifier.user=b.onDragModifier}if(b.onDrag&&b.onDrag.constructor==Function){this.dragCfg.onDrag=b.onDrag}if(b.containment&&((b.containment.constructor==String&&(b.containment=="parent"||b.containment=="document"))||(b.containment.constructor==Array&&b.containment.length==4))){this.dragCfg.containment=b.containment}if(b.fractions){this.dragCfg.fractions=b.fractions}if(b.grid){if(typeof b.grid=="number"){this.dragCfg.gx=parseInt(b.grid)||1;this.dragCfg.gy=parseInt(b.grid)||1}else{if(b.grid.length==2){this.dragCfg.gx=parseInt(b.grid[0])||1;this.dragCfg.gy=parseInt(b.grid[1])||1}}}if(b.onSlide&&b.onSlide.constructor==Function){this.dragCfg.onSlide=b.onSlide}this.isDraggable=true;e.each(function(){this.dragElem=d});e.bind("mousedown",jQuery.iDrag.draginit)})}};jQuery.fn.extend({DraggableDestroy:jQuery.iDrag.destroy,Draggable:jQuery.iDrag.build});


////////////////////// ////////// HGO Window Start Code ///////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////


(function ($) {

  var $t = $.telerik;

  $t.hgowindow = function (element, options) {
    $.extend(this, options);

    this.element = element;
    var $element = this.$element = $(element);
    this.elementId = $element.attr("id");

    // Div 'in css sınıfı adv-window olmalı.
    $element.attr('class', 'adv-window');

    // Width ve Height değerleri set edilir...
    $element.css('width', this.wndWidth);
    $element.css('height', this.wndHeight);

    // Header
    var header = this.header = $element.find('.adv-window-header').get(0);

    // For Move.
    if ((PageMethods.ieVersion > 8) || (!PageMethods.isIE))
    {
      $(header).css('cursor', 'move');
      $(header).children().css('cursor', 'move');
    }
  
    var builder = new $t.stringBuilder();
    if ((header == null) || (typeof (header) == 'undefined')) {
      builder.cat('<div id="adv-window-header" class="adv-window-header"> ');
      builder.cat('<img class="adv-window-header-icon" src="'+ imageUrl + '" />');
      builder.cat('<label class="adv-window-header-caption">' + this.titleWindow + ' </label>');
      builder.cat('</div> ');
    }
    if (builder.buffer.length > 0) {
      $(element).append(builder.string());
      builder.buffer = [];
    }

    // Content
    var content = this.content = $element.find('.adv-window-content').get(0);

    // Eğer Content var ve değiştirilmek isteniyor ise...
    if ($(content).children().length === 0)
      $(content).html(this.contentWindow);

    var $title = this.$title = $('#' + this.elementId + ' .adv-window-header label');

    // Eğer Title var ve değiştirilmek isteniyor ise...
    if ((this.titleWindow !== '') && (this.titleWindow !== null) && (typeof (this.titleWindow) !== 'undefined'))
      $title.text(this.titleWindow);

    if ($title.next().get(0) == null) {
      if ((this.closeLink == '' ) || (this.closeLink == null) || (typeof(this.closeLink) == 'undefined') )
        this.closeLink = '"' + this.closeLinkDefault + '"';

      //builder.cat('<a class="adv-window-close" href=' + this.closeLink + ' alt="Close">X</a> ');
      //if (builder.buffer.length > 0) {
      //  $(builder.string()).insertAfter($title);
      //  builder.buffer = [];
      //}
    }

    this.$wrapper = $element;

    this[this.enabled ? 'enable' : 'disable']();
    this.giveDragProperty();
  }

  $t.hgowindow.prototype =
  {
    giveDragProperty: function ()
    {
      /* Eğer Firefox yada Chrome ise Taşıma destekleniyor... IE 'de problem var... */
      //if ((PageMethods.isMozilla) || (PageMethods.isChrome) || (PageMethods.isIE9) || (PageMethods.isIE10))
      if ((PageMethods.ieVersion > 8) || (!PageMethods.isIE))
      { 
        //var idSearch = '"#' + $(header).attr('id') + '"';
        //var masterId = '"#' + $element.attr('id') + '"';

        var idSearch = '#' + $(this.header).attr('id');
        var masterId = '#' + this.$element.attr('id');
        $(masterId).Draggable({ zIndex: 5, ghosting:	false, opacity: 0.7, handle: idSearch, containment : 'parent' });

        //window.setTimeout("$(" + masterId + ").Draggable({ zIndex: 5, ghosting:	false, opacity: 0.7, handle:" + idSearch + ", containment : 'parent' });", 2);
      }
    },

    hide: function () {
      var wrapper = this.$wrapper;
      wrapper.hide();
    },

    show: function () {
      var wrapper = this.$wrapper;
      wrapper.show();
    },

    _update: function (text) {
      this._text(val);
    },

    _title: function (captionstr) {
      this.$title.text(captionstr);
    },

    enable: function () {
      this.enabled = true;
      this.$element.css("color", this.enableFontColor);
      this.$wrapper.removeClass('t-state-disabled');
    },

    disable: function () {
      this.enabled = false;
      this.$element.css("color", this.disableFontColor);
      this.$wrapper.addClass('t-state-disabled');
    },

    title: function (captionstr) {
      if (typeof (captionstr) === 'undefined' || captionstr === null)
        return this.$title.text();

      this._title(captionstr);
    },

    // Width set etme...
    width: function (value) {
      if (typeof (value) === 'undefined' || value === null)
        return this.$element.css('width');

      this.$element.css.width('width', value);
    },

    // Height set etme...
    height: function (value) {
      if (typeof (value) === 'undefined' || value === null)
        return this.$element.css('height');

      this.$element.css.height('height', value);
    }
  }

  $.fn.tHGOWindow = function (options) {
    var type = 'hgowindow';
    var defaults = $.fn.tHGOWindow.defaults[type];
    options = $.extend({}, defaults, options);
    options.type = type;

    return this.each(
                      function () {
                        var $element = $(this);
                        options = $.meta ? $.extend({}, options, $element.data()) : options;

                        if (!$element.data('tHGOWindow')) {
                          $element.data('tHGOWindow', new $t.hgowindow(this, options));
                          $t.trigger(this, 'load');
                        }
                      }
                    );
  };

  var commonDefaults =
  {
    titleWindow: 'AdvTicket Client Window',
    contentWindow: '<div class="firstRow" style="vertical-align:middle;"> </div>',
    enabled: true,
    // Window Width And Height...
    wndWidth: 400,  // Sample Value
    wndHeight: 250,  // Sample Value
    closeLink: '',
    closeLinkDefault: 'javascript:history.back()',
    imageUrl: 'HGO.axd?file=formicon.png'
  };

  $.fn.tHGOWindow.defaults = {
    hgowindow: $.extend(commonDefaults,
                                      {
                                        prop1: ''
                                      }
                        )
  };

})(jQuery);


// $('#HGOWindow').data('tHGOWindow').height(250)
// $('#HGOWindow').data('tHGOWindow').disable()
// $('#HGOWindow').data('tHGOWindow').enable()
// $('#HGOWindow').data('tHGOWindow').title('New Department 2')

